package demo1;

import java.util.Arrays;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-18
 */
public class Main {
    public static void bubleSort(Comparable[] arrs) {
        for (int i = 0; i < arrs.length - 1; i++) {
            for (int j = 0; j < arrs.length - 1 - i; j++) {
                if (arrs[j].compareTo(arrs[j+1]) > 0) {
                    Comparable tmp = arrs[j];
                    arrs[j] = arrs[j+1];
                    arrs[j+1] = tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        Student[] array = new Student[3];
        array[0] = new Student("ddd", 15);
        array[1] = new Student("bbb", 18);
        array[2] = new Student("ccc", 12);
/*        AgeComparator cmp = new AgeComparator();
        Arrays.sort(array, cmp);
        System.out.println(Arrays.toString(array));*/
        System.out.println(Arrays.toString(array));
        //Student.bubleSort(array);
        bubleSort(array);
        System.out.println(Arrays.toString(array));
    }
}
